<template>
  <div>
		<el-transfer :data="adminList" :props="props" :titles="titles" v-model="values"></el-transfer>
		<el-button style="margin-top: 10px;margin-left: 450px;" type="primary" plain @click="save">保存</el-button>
	</div>
</template>

<script setup>
import { get, post } from '@/axios'
import { ref, reactive } from 'vue'
// 实现一个roleId的props以及update:show 事件
const prop = defineProps(['roleId'])
const emits = defineEmits(['update:show'])
const adminList = ref([])
const props = reactive({
	label: 'name',
	key: 'id'
})
const titles = reactive(['未选用户', '已选用户'])
const values = ref([])
function getAdminList () {
	get('/adminRole/getAdmin', { roleId: prop.roleId }, content => {
		adminList.value = content.adminList
		for (const i in content.adminRoleList) {
			values.value.push(content.adminRoleList[i].adminId)
		}
	})
}
function save () {
	post('/adminRole/save', { roleId: prop.roleId, adminIds: values.value }, content => {
		emits('update:show', false)
	})
}
getAdminList()
</script>

<style scoped lang="scss">
</style>